package security.SecurityUtil;

/**
 * <p>类名: ThreadLocalContext</p>
 * <p>描述:TODO</p>
 * <p>创建人: liyp</p>
 * <p>创建时间: 2020/1/8 14:00</p>
 * <p>@version 2.0  </p>
 * <p>修改内容: ......</p>
 * <p>修改说明: ......</p>
 * <p>修改时间: ......</p>
 * <p>修改人: ......</p>
 * <p>每次修改，请增加上述修改信息说明</>
 */
public class ThreadLocalContext {

    private static ThreadLocal<UserInfo> userInfo = new ThreadLocal<>();
    private static ThreadLocal<String> loginWay = new ThreadLocal<>();

    public static UserInfo userInfo(){
        return userInfo.get();
    }
    public static String loginWay(){
        return loginWay.get();
    }

    public static void clear(){
        userInfo.remove();
        loginWay.remove();
    }

    public static void install(String accountId,String name,String loginway){
        userInfo.set(new UserInfo(accountId,name));
        loginWay.set(loginway);
    }
}
